﻿Imports System.Data.SqlClient

Public Class clsEvaluacionDetalle
    Private mintidEvaluacionDetalle As Integer
    Private mintEvaluacion As Integer
    Private mstrMes As String
    Private mintAnio As Integer
    Private mintLicencia As Integer
    Private mintTarjeton As Integer
    Private mintUniforme As Integer
    Private mintLimpieza As Integer
    Private mintVueltas As Integer
    Private mintTurnos As Integer
    Private mintFrecuencia As Integer
    Private mintDisciplina As Integer
    Private mintLiquidacio As Integer
    Private mdblTotal As Double
    Private mintIDEmpleado As Integer


    Public Property idEvaluacionDetalle() As Integer
        Get
            Return mintidEvaluacionDetalle
        End Get
        Set(ByVal value As Integer)
            mintidEvaluacionDetalle = value
        End Set
    End Property
    Public Property Evaluacion() As Integer
        Get
            Return mintEvaluacion
        End Get
        Set(ByVal value As Integer)
            mintEvaluacion = value
        End Set
    End Property
    Public Property Mes() As String
        Get
            Return mstrMes
        End Get
        Set(ByVal value As String)
            mstrMes = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property
    Public Property Licencia() As Integer
        Get
            Return mintLicencia
        End Get
        Set(ByVal value As Integer)
            mintLicencia = value
        End Set
    End Property
    Public Property Tarjeton() As Integer
        Get
            Return mintTarjeton
        End Get
        Set(ByVal value As Integer)
            mintTarjeton = value
        End Set
    End Property
    Public Property Uniforme() As Integer
        Get
            Return mintUniforme
        End Get
        Set(ByVal value As Integer)
            mintUniforme = value
        End Set
    End Property
    Public Property Limpieza() As Integer
        Get
            Return mintLimpieza
        End Get
        Set(ByVal value As Integer)
            mintLimpieza = value
        End Set
    End Property
    Public Property Vueltas() As Integer
        Get
            Return mintVueltas
        End Get
        Set(ByVal value As Integer)
            mintVueltas = value
        End Set
    End Property
    Public Property Turnos() As Integer
        Get
            Return mintTurnos
        End Get
        Set(ByVal value As Integer)
            mintTurnos = value
        End Set
    End Property
    Public Property Frecuencia() As Integer
        Get
            Return mintFrecuencia
        End Get
        Set(ByVal value As Integer)
            mintFrecuencia = value
        End Set
    End Property
    Public Property Disciplina() As Integer
        Get
            Return mintDisciplina
        End Get
        Set(ByVal value As Integer)
            mintDisciplina = value
        End Set
    End Property
    Public Property Liquidacio() As Integer
        Get
            Return mintLiquidacio
        End Get
        Set(ByVal value As Integer)
            mintLiquidacio = value
        End Set
    End Property
    Public Property Total() As Double
        Get
            Return mdblTotal
        End Get
        Set(ByVal value As Double)
            mdblTotal = value
        End Set
    End Property
    Public Property IDEmpleado() As Integer
        Get
            Return mintIDEmpleado
        End Get
        Set(ByVal value As Integer)
            mintIDEmpleado = value
        End Set
    End Property

    Public Sub New()
        mintidEvaluacionDetalle = 0
        mintEvaluacion = 0
        mstrMes = ""
        mintAnio = 0
        mintLicencia = 0
        mintTarjeton = 0
        mintUniforme = 0
        mintLimpieza = 0
        mintVueltas = 0
        mintTurnos = 0
        mintFrecuencia = 0
        mintDisciplina = 0
        mdblTotal = 0
        mintIDEmpleado = 0
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From EvaluacionOLDDetalle Where idempleado = " & IDEmpleado & " and mes='" & Mes & "'" & " and anio=" & Anio)

    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into EvaluacionOLDDetalle (" & _
                            "IdEvaluacionDetalle," & _
                            "IdEmpleado," & _
                            "Evaluacion," & _
                            "Mes," & _
                            "Anio," & _
                            "Licencia," & _
                            "Tarjeton," & _
                            "Uniforme," & _
                            "Limpieza," & _
                            "Vueltas," & _
                            "Turnos," & _
                            "Frecuencia," & _
                            "Disciplina," & _
                            "Total," & _
                            "Liquidacion) " & _
                            "VALUES (" & _
                            "@IdEvaluacionDetalle," & _
                            "@IdEmpleado," & _
                            "@Evaluacion," & _
                            "substring(@Mes,1,20)," & _
                            "@Anio," & _
                            "@Licencia," & _
                            "@Tarjeton," & _
                            "@Uniforme," & _
                            "@Limpieza," & _
                            "@Vueltas," & _
                            "@Turnos," & _
                            "@Frecuencia," & _
                            "@Disciplina," & _
                            "@Total," & _
                            "@Liquidacion)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdEvaluacionDetalle", mintidEvaluacionDetalle)
        Command.Parameters.AddWithValue("IdEmpleado", mintIDEmpleado)
        Command.Parameters.AddWithValue("Evaluacion", mintEvaluacion)
        Command.Parameters.AddWithValue("Mes", mstrMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Licencia", mintLicencia)
        Command.Parameters.AddWithValue("Tarjeton", mintTarjeton)
        Command.Parameters.AddWithValue("Uniforme", mintUniforme)
        Command.Parameters.AddWithValue("Limpieza", mintLimpieza)
        Command.Parameters.AddWithValue("Vueltas", mintVueltas)
        Command.Parameters.AddWithValue("Turnos", mintTurnos)
        Command.Parameters.AddWithValue("Frecuencia", mintFrecuencia)
        Command.Parameters.AddWithValue("Disciplina", mintDisciplina)
        Command.Parameters.AddWithValue("Total", mdblTotal)
        Command.Parameters.AddWithValue("Liquidacion", mintLiquidacio)


        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar la evaluacion", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub

End Class
